extends TextureRect


var equipment_wrapper : EquipmentWrapper


func _ready():
	equipment_wrapper = WrapperHelper.get_equipment(Global.player)
	equipment_wrapper.connect("loaded", self, "_equipment_loaded")
	equipment_wrapper.connect("unloaded", self, "_equipment_unloaded")

func _equipment_loaded(data):
	show_data(data)

func _equipment_unloaded(_data):
	show_data({})

func show_data(data: Dictionary):
	if data.size() > 0:
		var weapon : WeaponBean = JsonUtil.dict2object(data, WeaponBean)
		
		self.texture = weapon.texture
		self.hint_tooltip = """
ID：{id}
物品名称：{name}
图标：{icon}
攻击：{damage}
速度：{attack_speed}
距离：{distance}
描述：{desc}
金币：{coin}
""".format(data).strip_edges()
	else:
		texture = null
		hint_tooltip = ""


